#include <iostream>
using namespace std;

const int N = 110;

int T;
int n;
int a[N];
int f[N];
int res;

void resver(int a[]) //用于将字符串倒序，下标从1开始
{
    for (int i = 1; 2 * i <= n; ++i)
        swap(a[i], a[n + 1 - i]);
    return;
}

int main()
{
    freopen("cin.txt", "r", stdin);
    cin >> T;
    while (T--)
    {
        res = 0; //重置答案
        cin >> n;
        for (int i = 1; i <= n; ++i)
            cin >> a[i];
        for (int i = 1; i <= n; ++i)
        {
            f[i] = 1;                           //至少有我自己
            for (int j = 1; j < i; ++j)         //遍历前面的所有点
                if (a[i] < a[j])                //只有这样才能满足最大下降子序列
                    f[i] = max(f[i], f[j] + 1); //再选择是否要接在其后面
        }
        for (int i = 1; i <= n; ++i)
            res = max(res, f[i]);
        resver(a); //倒序
        //然后再来一遍
        for (int i = 1; i <= n; ++i)
        {
            f[i] = 1;
            for (int j = 1; j < i; ++j)
                if (a[i] < a[j])
                    f[i] = max(f[i], f[j] + 1);
            for (int i = 1; i <= n; ++i)
                res = max(res, f[i]);
        }
        cout << res << endl;
    }
    return 0;
}